//
//  SinaUserAccountModel.swift
//  SinaWeibo
//
//  Created by 王朝阳 on 2016/10/26.
//  Copyright © 2016年 wangzhaoyang. All rights reserved.
//

import UIKit
/// 创建 model 是为了保存数据的
class SinaUserAccountModel: NSObject, NSCoding {
    
    //用户授权的唯一票据
    var access_token: String?
    //access_token的生命周期.单位是秒数
    var expires_in:TimeInterval = 0 {
        
        didSet{
            expires_Date = Date().addingTimeInterval(expires_in)
        }
    }
    //授权用户的 UID
    var uid: String?
    //用户头像
    var avatar_large: String?
    //用户昵称
    var screen_name: String?
    //过期时间
    var expires_Date: Date?
    
    override init() {
        super.init()
    }
    ///归档
    func encode(with aCoder: NSCoder) {
        self.yy_modelEncode(with: aCoder)
    }
    ///解档
    required init?(coder aDecoder: NSCoder) {
        super.init()
        self.yy_modelInit(with: aDecoder)
    }
    
    //MARK: - 重写 description 方法
    override var description: String {
        let keys = ["access_token", "expires_in", "uid", "avatar_large", "screen_name"]
        return dictionaryWithValues(forKeys: keys).description
   
    }

}
